package com.lijin.batchsys.framework.control;

import com.lijin.batchsys.framework.common.BatchSysException;
import com.lijin.batchsys.framework.dao.model.JobInfo;

public class BatchSysFlowJob extends BatchSysAbstractJob {

	public BatchSysFlowJob(JobInfo jobInfo) {
		super(jobInfo);
	}

	protected void doExecute(BatchExecContext batchCtx) {
		
		for (BatchSysStep step : steps) {
			try {
				handleStep(step, batchCtx);
			} catch (Exception e) {
				StringBuilder errMsg = new StringBuilder();
				if (step.canSkip()) {
					this.addErrStep(step.getStepInfo());
				} else {
					if (e instanceof BatchSysException) {
						throw (BatchSysException) e;
					} else {
						throw new BatchSysException(errMsg.toString(), e);
					}
				}
			}
		}
	}
}
